//
//  TReleaseHistoryViewController.m
//  LoveShare
//
//  Created by ways on 2017/5/3.
//  Copyright © 2017年 tikeyc. All rights reserved.
//

#import "TReleaseHistoryViewController.h"

#import "TMyAttentionUserDetailHeadView.h"

#import "TFindDriverListViewController.h"
#import "TFindPassengerListViewController.h"
#import "THomeHelperListViewController.h"
#import "TShoppingListViewController.h"
#import "TSellThingsListViewController.h"
#import "THealthyLifeListViewController.h"

@interface TReleaseHistoryViewController ()

@property (nonatomic,strong)TMyAttentionUserDetailHeadView *myAttentionUserDetailHeadView;

@end

@implementation TReleaseHistoryViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    self.edgesForExtendedLayout = UIRectEdgeNone;
    
    self.title = @"发布记录";
    [self initProperty];
    [self setChildViewControllers];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    if (_isOhterUserDetail) {
        [self.navigationController setNavigationBarHidden:YES animated:YES];
    } else {
        [self.navigationController setNavigationBarHidden:NO animated:YES];
    }
    
}

- (void)viewWillDisappear:(BOOL)animated {
    [self.navigationController setNavigationBarHidden:NO animated:NO];
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

#pragma mark - init 


- (void)initProperty {
    self.titleScrollViewColor = TColor_RGBA(69, 107, 180, 0.5);
}

- (TMyAttentionUserDetailHeadView *)myAttentionUserDetailHeadView {
    if (_myAttentionUserDetailHeadView == nil) {
        _myAttentionUserDetailHeadView = [TMyAttentionUserDetailHeadView loadFromNib];
        [self.view addSubview:_myAttentionUserDetailHeadView];
        [_myAttentionUserDetailHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@0);
            make.top.equalTo(@0);
            make.right.equalTo(@0);
            make.height.equalTo(@140);
        }];
    }
    return _myAttentionUserDetailHeadView;
}

- (void)setChildViewControllers{
    
    NSArray *controllers = @[@"TFindDriverListViewController",@"FindPassengerListViewController",@"THomeHelperListViewController",
                             @"TShoppingListViewController",@"TSellThingsListViewController",@"THealthyLifeListViewController",];
    NSArray *titles = @[@"找司机",@"找乘客",@"令居帮手",
      @"买东西",@"卖东西",@"健康生活",];
    for (int i = 0; i < controllers.count; i++) {
        Class class = NSClassFromString(controllers[i]);
        UIViewController *controller = [[class alloc] init];
        controller.title = titles[i];
        
        if (controller) {
            [self addChildViewController:controller];
        }
        
    }
    
    //TWeakSelf(self)
    CGFloat topGap = 0;
    if (_isOhterUserDetail) {
        [self myAttentionUserDetailHeadView];
        topGap = 140;
    }
    [self setUpContentViewFrame:^(UIView *contentView) {
        //contentView.frame = weakself.view.frame;
        [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@0);
            make.top.equalTo(@(topGap));
            make.right.equalTo(@0);
            make.bottom.equalTo(@0);
        }];
    }];
}

@end
